package map_;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

@SuppressWarnings({"all"})
public class Map_ {
    public static void main(String[] args) {

        //1.通过key取出所有的values
        Map map = new HashMap();
        map.put("01 ", "小白");
        map.put("02","小青");
        map.put("03","小黑");
        Set keyset = map.keySet();
        for (Object key :keyset) {
            System.out.println(key + " " + map.get(key));
        }
        System.out.println("============");
        Iterator iterator = keyset.iterator();
        while (iterator.hasNext()) {
            Object key =  iterator.next();
            System.out.println(key + " " + map.get(key));
        }

        //2.EntrySet获取key-value
        Set entrySet = map.entrySet();
        for (Object entry :entrySet) {
            Map.Entry m = (Map.Entry) entry;
            System.out.println(m.getKey() + "----" + m.getValue());
        }
        System.out.println("===========");
        Iterator iterator1  = entrySet.iterator();
        while (iterator1.hasNext()) {
            Object entry =  iterator1.next();
            Map.Entry m = (Map.Entry) entry;
            System.out.println(m.getKey() + "----" + m.getValue());
        }
    }
}